home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / C / MSDOS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-24  |  1.6 KB  |  71 lines

  1. /* MSDOS.C
  2.  ************************************************************************
  3.  *                                    *
  4.  *        PC Scheme/Geneva 4.00 Borland C code            *
  5.  *                                    *
  6.  * (c) 1985-1988 by Texas Instruments, Inc. See COPYRIGHT.TXT        *
  7.  * (c) 1992 by L. Bartholdi & M. Vuilleumier, University of Geneva    *
  8.  *                                    *
  9.  *----------------------------------------------------------------------*
  10.  *                                    *
  11.  *        Special MesS-DOS File Functions                *
  12.  *                                    *
  13.  *----------------------------------------------------------------------*
  14.  *                                    *
  15.  * Created by: L. Bartholdi        Date: 1992            *
  16.  * Revision history:                            *
  17.  * - 18 Jun 92:    Renaissance (Borland Compilers, ...)            *
  18.  *                                    *
  19.  *                    ``In nomine omnipotentii dei''    *
  20.  ************************************************************************/
  21.  
  22. #include    <stdlib.h>
  23. #include    "scheme.h"
  24.  
  25. #define    IOBUFSIZE    4096
  26.  
  27. int    copy_file(char *source, char *dest)
  28. {
  29.     int        hsource, hdest, count;
  30.     unsigned long    len;
  31.     void        *buffer;
  32.  
  33.     if( (buffer = malloc(IOBUFSIZE)) == NULL )
  34.         return    -1;
  35.  
  36.     if( zopen( &hsource, source, 0, &len ) )
  37.     {
  38.         free(buffer);
  39.         return    -1;
  40.     }
  41.     if( zcreate( &hdest, dest ) )
  42.     {
  43.         free(buffer);
  44.         return    -1;
  45.     }
  46.  
  47.     while( !zread( hsource, buffer, &(count = IOBUFSIZE) ) && count )
  48.     if( zwrite( hdest, buffer, &count ) )
  49.     {
  50.         free(buffer);
  51.         return    -1;
  52.     }
  53.  
  54.     free(buffer);
  55.     zclose(hsource);
  56.     zclose(hdest);
  57.  
  58.     return    0;
  59. }
  60.  
  61.  
  62. long    filesize( char *filename )
  63. {
  64.     int             handle;
  65.     unsigned long    size = -1;
  66.  
  67.     if( zopen( &handle, filename, 0, &size ) )
  68.         zclose(handle);
  69.     return    size;
  70. }
  71.